﻿using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using XnaPlus.Common;
using XnaPlus.Common.Extensions;
using XnaPlus.Common.Interfaces;

namespace EscapeZone
{
    public class Cursor : DrawableGamePlusComponent, IPositionable 
    {
        private readonly Texture2D m_texture;
        private new EscapeGame Game { get { return base.Game as EscapeGame; } }

        public Color Color { get; set; }

        public Cursor(EscapeGame game, Texture2D texture) : base(game)
        {
            m_texture = texture;
        }

        public Vector2 Position { get; private set; }

        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);
            Position = Game.InputState.MousePosition.ToVector();
        }

        public override void Draw(GameTime gameTime)
        {
            base.Draw(gameTime);
            Game.SpriteBatch.Draw(m_texture, Position - m_texture.Rect().Size()/2, Color);
        }
    }
}